home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / wb / czesc_2 / iconextras / src / deleteicon / deleteicon.c < prev    next >
C/C++ Source or Header  |  1995-01-13  |  1KB  |  50 lines

  1. #include <exec/types.h>
  2. #include <workbench/workbench.h>
  3. #include <workbench/startup.h>
  4. #include <libraries/dos.h>
  5.  
  6. #include <clib/alib_protos.h>
  7. #include <clib/icon_protos.h>
  8. #include <clib/dos_protos.h>
  9. #include <clib/exec_protos.h>
  10.  
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <string.h>
  14.  
  15. void cleanexit(int error);
  16.  
  17. struct Library *IconBase = NULL;
  18. struct DiskObject *dobj = NULL;
  19.  
  20. void main(int argc,char *argv[]) {
  21.  
  22.     if(argc!=2) {
  23.         printf("Usage:\n");
  24.         printf("%s <file [.info]>");
  25.         cleanexit(RETURN_OK);
  26.     }
  27.  
  28.     if(!(IconBase=OpenLibrary("icon.library",33))) {
  29.         printf("Couldn't open icon.library\n");
  30.         cleanexit(RETURN_FAIL);
  31.     }
  32.  
  33.     /* Strip .info from end of each filename if it ends that way */
  34.     if(strlen(argv[1]) > 5 && !strcmp(&argv[1][strlen(argv[1])-5],".info"))
  35.         argv[1][strlen(argv[1])-5]='\0';
  36.  
  37.     if(!(DeleteDiskObject(argv[1]))) {
  38.         printf("File not deleted\n");
  39.         cleanexit(RETURN_FAIL);
  40.     }
  41.  
  42.     cleanexit(RETURN_OK);
  43. }
  44.  
  45. void cleanexit(int error) {
  46.     if(IconBase) CloseLibrary(IconBase);
  47.     if(dobj) FreeDiskObject(dobj);
  48.     exit(error);
  49. }
  50.